<!--
*@creditAuthorizationResults
*@author lijiaqi
*@date 2024/01/05 09:04
-->
<template>
  <div class="pre-screening-results">
    <div class="resultsStatus">
      <template v-if="type == '' || type == undefined">
        <van-icon name="checked"/>
        <p class="title">征信授权成功</p>
        <p class="refuseTip">资信授权已完成，贷款审核中，审核成功后将以短信通知借款人</p>
      </template>
      <template v-if="type == 'refuse'">
        <van-icon name="clear"/>
        <p class="title">征信授权失败</p>
        <p class="refuseTip">资信授权失败，贷款正在审核中，届时我行客户经理将电话联系贷款申请人</p>
      </template>
<!--      <template v-if="type == 'await'">-->
<!--        <van-icon name="clock"/>-->
<!--        <p class="title">借款申请中</p>-->
<!--        <p class="refuseTip" style="text-align: center">预计15分钟后会有短信通知你结果</p>-->
<!--      </template>-->
    </div>
    <div class="btn-group">
      <div class="btn">
        <router-link :to="{ path:'/loanPage/newHome' }">返回首页</router-link>
      </div>
      <div class="btn btn-primary" v-if="type == 'refuse'">
        <router-link :to="{ path:'/loanPage/newHome' }">重新授权</router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "borrowingResults",
  props: ['type', 'phoneNum', 'dataObj'],
  components: {},
  data() {
    return {
      dataList: [],
      successTime: ''
    }
  },
  computed: {},
  watch: {},
  created() {
    let sTime = this.dataObj['WF_CONTRAC_DRAW_INFO']['UPDATE_TIME_']
    this.successTime = sTime.split(' ')[0]
    let hk = this.successTime.split('-')
    let year = this.dataObj['WF_CONTRAC_DRAW_INFO']['LOAN_DEADLINE'] / 12

    console.log("hahahahahahahah", this.dataObj)
    this.dataList = [
      {
        name: '借款金额',
        value: this.dataObj['WF_CONTRAC_DRAW_INFO']['LOAN_AMT'] + '元'
      },
      {
        name: '借款用途',
        type: 'dict',
        value: this.dataObj['WF_CONTRAC_DRAW_INFO']['LOAN_USE']
      },
      {
        name: '供款日',
        value: this.dataObj['WF_CONTRAC_DRAW_INFO']['CONTRIBUTION_DAY']
      },
      {
        name: '借款利率',
        value: this.dataObj['WF_CONTRAC_DRAW_INFO']['LENDING_RATE'] + '%'
      },
      {
        name: '贷款到期日',
        value: parseInt(hk[0]) + year + '年' + hk[1] + "月" + hk[2] + '日'
      },
      {
        name: '收/还款账户',
        value: this.dataObj['WF_CONTRAC_DRAW_INFO']['REPAY_ACCOUNT']
      },
    ]

    //  更改合同状态
    this.updateStatus(this.dataObj)
  },
  mounted() {
  },
  methods: {
    /**
     * 更改合同状态
     * @param item
     */
    updateStatus(item) {
      this.$toast.loading({
        duration: 0, // 持续展示 toast
        forbidClick: true,
        message: '加载中...'
      });
      let param = {
        contractId: item['CONTRACT_ID'],//合同编号
        amtStr: item['WF_CONTRAC_DRAW_INFO']['LOAN_AMT'],//更新额度
      }
      this.baseService.postForm(this.__ctx + '/plugin/mobileBusiCenter/saveUsageAmt ', param).then(res => {
        this.$toast.clear();
        if (res.isOk) {
          //如果又返回taskid
          console.log("------", res)

        } else {
          this.$toast({
            icon: 'warning',
            message: res.msg
          });
        }
      }, function (status) {
        this.$toast.clear();
        if (status == !0) {
          this.$toast({
            icon: 'warning',
            message: '加载失败！' + status
          });
        }
      });
    },
  }
}
</script>

<style scoped lang="less">
//.content_box {
//  margin: 5.8rem 0rem 0rem 0rem;
//}

.pre-screening-results {
  font-size: 1.3rem;
  line-height: 2rem;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: rgb(134, 144, 156);
  background-color: #FFFFFF;
  height: calc(100vh - 5.8rem);
  position: relative;
}

.pre-screening-results .resultsStatus {
  padding: 4rem;
  text-align: center;
}

.pre-screening-results .refuseTip {
  color: rgb(134, 144, 156);
  font-family: HarmonyOS Sans SC;
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  //letter-spacing: 0px;
  text-align: left;
}

.pre-screening-results .van-icon-clear {
  color: rgb(254, 93, 61) !important;
  font-size: 6rem;
}

.pre-screening-results .van-icon-checked {
  color: rgb(97, 210, 67) !important;
  font-size: 6rem;
}

.pre-screening-results .van-icon-clock {
  color: #F7B501 !important;
  font-size: 6rem;
}

.pre-screening-results .title {
  font-size: 2rem;
  color: rgb(78, 89, 105);
  margin: 1.6rem;
}

.pre-screening-results .btn-group {
  display: flex;
  justify-content: center;
}

.pre-screening-results .btn {
  width: 30%;
  padding: 6px 0;
  font-size: 1.4rem;
  font-weight: 400;
  text-align: center;
  border-radius: 4.4rem;
  margin: 0 0.8rem;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.pre-screening-results .btn a {
  color: var(--primary-color);
}

.pre-screening-results .btn-primary {
  color: #ffffff;
  border: 1px solid var(--primary-color);
  background: var(--primary-color);
}

.pre-screening-results .btn-primary a {
  color: #ffffff;
}

//反显借款信息区域
.conten_box {
  background-color: #f6f8f9;
  margin: 3.8rem 1.6rem 0 1.6rem;
  border-radius: 1rem;

  .item_one {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    margin: 0 1.6rem;
    padding: 1.2rem 0px;

    .label {
      width: 8rem;
      margin-right: 2.4rem;
      color: rgba(29, 33, 41, 0.54);
      font-family: HarmonyOS Sans SC;
      font-size: 14px;
      font-weight: 400;
      line-height: 18px;
      //letter-spacing: 0px;
      text-align: left;
    }

    .right {
      color: rgb(29, 33, 41);
      font-family: HarmonyOS Sans SC;
      font-size: 14px;
      font-weight: 400;
      line-height: 18px;
      //letter-spacing: 0px;
      text-align: left;
    }
  }

}
</style>
